using System;
using System.Collections.Generic;
using System.Text;
using SP.Parameter;

namespace SP.HwLowProfileRS
{
    /// <summary>
    /// A simple base map feature
    /// </summary>
    public class AlphaMapFusion : AbstractFusion
    {
        public AlphaMapFusion()
        {
            // param alphaMap
            AddParameter(
                new Texture2dParamter("alphaMap", "alphaMapSamp")
                .SetSRGBTexture(true)
                .SetDesc("UV channel 1; R: alpha; GBA: unused")
                .SetForceSamplerId(1)
                );
        }

        public override string Name
        {
            get { return "AlphaMap"; }
        }

        public override string Desc
        {
            get { return "Enable this fusion to support alpha map effect."; }
        }

        public override Stage Stage
        {
            get { return Stage.Opacity; }
        }

        public override int UVChannelCount
        {
            get { return 2; }
        }

        public override void Code(StringBuilder b, string platform)
        {
            AddLine(b, "vec4 alphaMap = tex2D(alphaMapSamp, pipeline.Texcoord[1]);");
            AddLine(b, "pipeline.Opacity *= alphaMap.r;");
        }
    }
}
